/**
 * 文章标签
 */
const mongoose = require('mongoose')
const shortid = require('shortid')
const moment = require('moment')
const Schema = mongoose.Schema

const PostTagSchema = new Schema({
  _id: {
    type: String,
    default: shortid.generate
  },
  name: String,  // 标签名
  alias: String, // 标签别名
  description: String, // 分类描述
  cover: String, // 标签图片 / 字体图标
  create_time: {
    type: Date,
    default: Date.now
  },
  group:{
    type: String,
    default:''
  }, 
  // 是否激活
  enable: {
    type: Boolean,
    default: true
  },
  clicks: {
    type: Number,
    default: 0
  }
})

PostTagSchema.path('create_time').get(function (v) {
  return moment(v).utc().utcOffset(-8).format("YYYY-MM-DD")
})

module.exports = mongoose.model('PostTag', PostTagSchema)